package com.huitongmaoyi.ai;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    private static final int PORT = 8888;

    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(PORT)) {
            System.out.println("服务器启动，监听端口 " + PORT + "，等待用户连接...");
            while (true) {
                Socket clientSocket = serverSocket.accept();
                System.out.println("新用户连接：" + clientSocket.getInetAddress());
                new Thread(new UserSessionHandler(clientSocket)).start();
            }
        } catch (IOException e) {
            System.err.println("服务器异常：" + e.getMessage());
        }
    }
}